home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / speed-text.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  3.3 KB  |  96 lines

  1. ; Speed text
  2. ; Copyright (c) 1998 Austin Donnelly <austin@greenend.org.uk>
  3. ;
  4. ;
  5. ; Based on alien glow code from Adrian Likins
  6. ; This program is free software; you can redistribute it and/or modify
  7. ; it under the terms of the GNU General Public License as published by
  8. ; the Free Software Foundation; either version 2 of the License, or
  9. ; (at your option) any later version.
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19. (define (script-fu-speed-text string font font-size density text-color bg-color)
  20.   (let* ((text-ext (gimp-text-get-extents-fontname string font-size PIXELS font))
  21.      (wid (+ (car text-ext) 20))
  22.      (hi  (+ (nth 1 text-ext) 20))
  23.      (img (car (gimp-image-new wid hi RGB)))
  24.      (bg-layer (car (gimp-layer-new img wid hi  RGB-IMAGE "Background" 100 NORMAL-MODE)))
  25.      (text-layer (car (gimp-layer-new img wid hi  RGBA-IMAGE "Text layer" 100 NORMAL-MODE)))
  26.      (text-mask 0)
  27.      (saved-select 0)
  28.      (cell-size (/ font-size 8))
  29.      (grey (/ (* density 255) 100))
  30.      (saved-sel))
  31.  
  32.     (gimp-context-push)
  33.  
  34.     (gimp-image-undo-disable img)
  35.     (gimp-image-add-layer img bg-layer 1)
  36.     (gimp-image-add-layer img text-layer -1)
  37.  
  38.     (gimp-context-set-background bg-color)
  39.     (gimp-edit-clear bg-layer)
  40.     (gimp-edit-clear text-layer)
  41.  
  42.     (gimp-floating-sel-anchor (car (gimp-text-fontname img text-layer 10 10 string 0 TRUE font-size PIXELS font)))
  43.  
  44.     ; save the selection for later
  45.     (gimp-selection-layer-alpha text-layer)
  46.     (set! saved-sel (car (gimp-selection-save img)))
  47.  
  48.     ; add layer mask
  49.     (set! text-mask (car (gimp-layer-create-mask text-layer ADD-ALPHA-MASK)))
  50.     (gimp-layer-add-mask text-layer text-mask)
  51.  
  52.     ; grow the layer
  53.     (gimp-layer-set-edit-mask text-layer FALSE)
  54.     (gimp-selection-grow img 10)
  55.     (gimp-context-set-foreground text-color)
  56.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  57.  
  58.     ; feather the mask
  59.     (gimp-layer-set-edit-mask text-layer TRUE)
  60.     (gimp-selection-load saved-sel)
  61.     (gimp-selection-feather img 10)
  62.     (gimp-context-set-background (list grey grey grey))
  63.     (gimp-edit-fill text-mask BACKGROUND-FILL)
  64.     (gimp-edit-fill text-mask BACKGROUND-FILL)
  65.     (gimp-edit-fill text-mask BACKGROUND-FILL)
  66.     (gimp-selection-none img)
  67.  
  68.     (plug-in-newsprint 1 img text-mask cell-size 0 0 0.0 1 45.0 0 45.0 0 45.0 0 5)
  69.  
  70.     (gimp-layer-remove-mask text-layer MASK-APPLY)
  71.  
  72.     (gimp-image-undo-enable img)
  73.     (gimp-display-new img)
  74.  
  75.     (gimp-context-pop)))
  76.  
  77. (script-fu-register "script-fu-speed-text"
  78.             _"Speed Text..."
  79.             "give text a speedy effect"
  80.             "Austin Donnelly"
  81.             "Austin Donnelly"
  82.             "1998"
  83.             ""
  84.             SF-STRING     _"Text"               "Speed!"
  85.             SF-FONT       _"Font"               "Charter"
  86.             SF-ADJUSTMENT _"Font size (pixels)" '(100 2 1000 1 10 0 1)
  87.             SF-ADJUSTMENT _"Density (%)"        '(80 0 100 1 10 0 0)
  88.                     SF-COLOR      _"Text color"         '(0 0 0)
  89.             SF-COLOR      _"Background color"   '(255 255 255))
  90.  
  91. (script-fu-menu-register "script-fu-speed-text"
  92.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  93.